﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using _Point = System.Windows.Point;
using System.Windows;
using System.Windows.Shapes;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;

namespace editor
{
    public static class XMLExtensions
    {
        public static void WriteAsXML(this Point point, System.Xml.XmlTextWriter textWriter)
        {
            textWriter.WriteStartElement("Point");
            textWriter.WriteAttributeString("X", point.X.ToString());
            textWriter.WriteAttributeString("Y", point.Y.ToString());
            textWriter.WriteEndElement();
        }
        public static void WriteAsXML(this Stroke polygon, System.Xml.XmlTextWriter textWriter)
        {
            textWriter.WriteStartElement("Polygon");
            textWriter.WriteAttributeString("PointsQTY", polygon.StylusPoints.Count.ToString());
            textWriter.WriteAttributeString("Color", polygon.DrawingAttributes.Color.ToString());
            
            textWriter.WriteStartElement("Points");

            foreach (StylusPoint SPoint in polygon.StylusPoints)
            {
                SPoint.ToPoint().WriteAsXML(textWriter);
            }
            textWriter.WriteEndElement();
            textWriter.WriteEndElement();
        }
    }
}
